package single

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/go-xorm/xorm"
	"github.com/go-xorm/core"
)

var engine *xorm.Engine
func init() {
	var err error
	engine, err = xorm.NewEngine("mysql", "root:mysqltest@tcp(fsdev.me:3306)/jujubao?charset=utf8")
	tbMapper := core.NewPrefixMapper(core.SnakeMapper{}, "ju_")
	engine.SetTableMapper(tbMapper)
	engine.SetColumnMapper(core.SameMapper{})
	if err != nil {
		fmt.Println(err)
		fmt.Println("数据库连接异常！")
	}

}

func Get() *xorm.Engine {
	return engine
}
